package com.sinochem.yunlian.ship.common.enums;

import lombok.Getter;

/**
 * @author: houshihao
 * @description:im 运单消息类型
 *  //消息类型(
 *           1xx 节点变更日志（100：完成任务；110：提交异常；120：消除异常）  节点变更vs 任务完成  ？？
 *           2xx群操作（200:群创建；210：加入群；220：踢出群；）
 *           3xx任务分配（300：未入群时分配任务；310：入群后分配任务）
 * @date: 2018/3/27 11:05
 **/
@Getter
public enum ChatMsgTypeEnum {
    TASK_FINSHED(100 , "完成任务","sys",
            ChatMsgTypeEnum.fcSBlueTag +"%s %s"+ ChatMsgTypeEnum.fcETag +"完成了"+ ChatMsgTypeEnum.fcSBlueTag +" %s港%s "+ ChatMsgTypeEnum.fcETag +"任务，"+ ChatMsgTypeEnum.fcSBlueTag +"猛戳>>去查看"+ ChatMsgTypeEnum.fcETag +""),
//    TASK_AUTO_FINSHED(101 , "完成任务(智能签收)","sys",
//            "“船运帮”智能完成了"+ ChatMsgTypeEnum.fcSBlueTag +" %s港%s "+ ChatMsgTypeEnum.fcETag +"任务，"+ ChatMsgTypeEnum.fcSBlueTag +"猛戳>>去查看"+ ChatMsgTypeEnum.fcETag +""),
    TASK_COMMIT_EXCEPTION(110 , "提交异常","sys",
            ChatMsgTypeEnum.fcSBlueTag +"%s %s"+ ChatMsgTypeEnum.fcETag +"提交了"+ ChatMsgTypeEnum.fcSBlueTag +"%s"+ ChatMsgTypeEnum.fcETag +"异常，"+ ChatMsgTypeEnum.fcSBlueTag +"猛戳>>去查看"+ ChatMsgTypeEnum.fcETag +""),
    TASK_CANCLE_EXCEPTION(120 , "消除异常","sys",
            ChatMsgTypeEnum.fcSBlueTag +"%s %s"+ ChatMsgTypeEnum.fcETag +"清除了"+ ChatMsgTypeEnum.fcSBlueTag +"%s "+ ChatMsgTypeEnum.fcETag +"异常，"+ ChatMsgTypeEnum.fcSBlueTag +"猛戳>>去查看"+ ChatMsgTypeEnum.fcETag +""),

    IM_GROUP_CREATED(200 , "群创建","shipMi",
            "欢迎加入【%s任务帮】，入帮后看船报、聊天、跟踪信息，想看就看，想查就查。请先为运单"+ ChatMsgTypeEnum.fcSBlueTag +"分配任务"+ ChatMsgTypeEnum.fcETag +"。"),
    IM_GROUP_ADD(210 , "加入群","sys",
            ChatMsgTypeEnum.fcSBlueTag +"%s %s"+ ChatMsgTypeEnum.fcETag +"邀请"+ ChatMsgTypeEnum.fcSBlueTag +"%s %s"+ ChatMsgTypeEnum.fcETag +"加入了任务帮"),
    IM_GROUP_DEL(220 , "踢出群","sys",
            ChatMsgTypeEnum.fcSBlueTag +"%s"+ ChatMsgTypeEnum.fcETag +"将你请出了任务帮"),

    TASK_ASSIGN_NOT_INGROUP(300 , "未入群时分配任务","shipMi",
            ChatMsgTypeEnum.fcSBlueTag +"%s %s"+ ChatMsgTypeEnum.fcETag +"，您好！欢迎加入【%s任务帮】，"+ ChatMsgTypeEnum.fcSBlueTag +"%s %s"+ ChatMsgTypeEnum.fcETag +"为您分配了任务。"),
    TASK_ASSIGN_INGROUP(310 , "入群后分配任务","shipMi",
            ChatMsgTypeEnum.fcSBlueTag +"%s %s"+ ChatMsgTypeEnum.fcETag +"，您好！"+ ChatMsgTypeEnum.fcSBlueTag +"%s %s"+ ChatMsgTypeEnum.fcETag +"为您分配了任务。");

    private Integer type;
    private String desc;
    private String msgLevel;
    private String message;

    ChatMsgTypeEnum(Integer type, String desc, String msgLevel, String message) {
        this.type = type;
        this.msgLevel = msgLevel;
        this.desc = desc;
        this.message = message;
    }

    //根据消息类型获取msg
    public static String  getMsgByType(Integer type) {
        for (ChatMsgTypeEnum messageType : values()) {
            if (messageType.getType().equals(type)) {
                return messageType.getMessage();
            }
        }
        return "";
    }

    //根据消息类型获取WayBillMessageType
    public static ChatMsgTypeEnum getWayBillMessageTypeByType(Integer type) {
        for (ChatMsgTypeEnum messageType : values()) {
            if (messageType.getType().equals(type)) {
                return messageType;
            }

        }
        return null;
    }

    public static final String fcSBlueTag = "<font color=\"#0062FD\">";   //font color start blue tag
    public static final String fcETag = "</font>";                        //font color end tag
    public static final String autoCompleteName = "“船运帮”智能";

    public static void main(String[] args) {
        System.out.println(ChatMsgTypeEnum.TASK_FINSHED.getMessage());
        System.out.println(ChatMsgTypeEnum.TASK_FINSHED.getMessage().replaceAll(ChatMsgTypeEnum.fcSBlueTag, "").replaceAll(ChatMsgTypeEnum.fcETag, ""));
    }

}